package com.ljkj.blockpay.ui.activity;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;

import com.kongzue.baseokhttp.util.JsonMap;
import com.ljkj.blockpay.R;
import com.ljkj.blockpay.basedata.BaseActivity;
import com.ljkj.blockpay.databinding.ActivityChangePasswordBinding;
import com.ljkj.blockpay.presenter.PasswordPresenter;
import com.ljkj.blockpay.presenter.inter.PasswordInter;
import com.ljkj.blockpay.util.ToggleToActivity;
import com.ljkj.blockpay.widget.ClickListener;
import com.luck.picture.lib.tools.ToastUtils;

/**
 * 修改登录密码页面
 */
public class ChangePasswordActivity extends BaseActivity<ActivityChangePasswordBinding, PasswordPresenter>implements PasswordInter.PasswordInterView, ClickListener {

    private String oldpwd;
    private String newpwd;
    private String confirmpwd;

    @Override
    public int initContentView() {
        return R.layout.activity_change_password;
    }

    @Override
    protected PasswordPresenter createPresenter() {
        return new PasswordPresenter(this,this);
    }

    @Override
    protected void init(Bundle savedInstanceState) {

    }

    @Override
    protected void initData() {
        super.initData();
        binding.tvTitle.setLeftBackFinish(this);
        oldpwd = binding.etOldpwd.getText().toString();
        newpwd = binding.etInputnewpwd.getText().toString();
        confirmpwd = binding.etConfirmlogin.getText().toString();
    }

    @Override
    public void onClick(View view) {

        switch (view.getId()){
            case R.id.tv_foundpwd:
                ToggleToActivity.toResetPwdActivity(this);
                break;
            case R.id.iv_oldpwdeye:

                break;
            case R.id.iv_newpwdeye:

                break;
            case R.id.btn_bindchange:
                if (oldpwd == null){
                    ToastUtils.s(this,"请输入旧密码");
                } else if (newpwd == null){
                    ToastUtils.s(this,"请输入新密码");
                } else if (confirmpwd == null){
                    ToastUtils.s(this,"请确认新密码");
                } else if (!newpwd.equals(confirmpwd)){
                    ToastUtils.s(this,"俩次密码输入不一致");
                }
                else {

                    getPresenter().changePwd(newpwd,oldpwd);
                }

                break;
            default:
                break;
        }
    }

    @Override
    public void changeSuccess(JsonMap jsonMap) {

    }

    @Override
    public void resetSuccess(JsonMap jsonMap) {

    }
}